docs: remove unnecessary return in example#3908
Conversation
No need to return `abortNavigation` and `navigateTo` in `defineNuxtRouteMiddleware`
|
Thanks for PR @harmyderoman. Indeed they are not needed but semantically making example readable that calling those functions causes rest of the logic to stop. Besides navigateTo is likely to return a promise which preserving chain is better than discarding. |
|
@pi0 Every time I tried |
|
It shouldn't. I'll investigate. |
|
Would you share a reproduction @harmyderoman? 🙏 |
|
Sorry guys, I did that infinity loop by trying to run |
|
No worries @harmyderoman and indeed thanks for sharing the cause. I think we might have improved redirectTo to avoid such loops. |
|
Cool! So I'll close this PR. |
I also did that infinity loop by trying to run What is the correct writing method? |
|
@lixiaofa |
|
You should not navigate to the current path as that will perform an extra navigation. Just return: if (whitelist.includes(to.path)) {
return
}You can read more on https://router.vuejs.org/guide/advanced/navigation-guards.html#navigation-guards. |
All permissions will be separated if they do not return. |
Thank you very much! |


No need to return
abortNavigationandnavigateToindefineNuxtRouteMiddleware🔗 Linked issue
❓ Type of change
Docs
📚 Description
No need to return
abortNavigationandnavigateToindefineNuxtRouteMiddleware📝 Checklist